from xml.etree.ElementTree import SubElement
from DemConfig.DtcInput import DemDtcCfg
from ArxmlBasicTools.Arxml import *

class DemDTCConfig(arxmlFile):

    DemContainers_el = 'no define'
    DemConfigSetContainers_el = 'no define'
    DemGeneralContainers_el = 'no define'

    def __init__(self) -> None:
        super(DemDTCConfig, self).__init__()
        self.Project_el = self.createArxmlPackage('ETAS_Project/EcucModuleConfigurationValuess')

    def addDtcEnableConditionGroup_cfg(self,DemEnCondGroupKey,DemEnCondList):
        if self.DemContainers_el == 'no define':
            self.DemContainers_el = addModule(self.Project_el,'Dem',r'/AUTOSAR_Dem/EcucModuleDefs/Dem')
        if self.DemGeneralContainers_el == 'no define':
            self.DemGeneralContainers_el = addContainer(self.DemContainers_el,'DemGeneral','ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemGeneral')
            self.DemGeneralContainers_el = SubElement(self.DemGeneralContainers_el,'SUB-CONTAINERS')
            
        DemGeneralSUB_CONTAINERS_el = self.DemGeneralContainers_el

        DemEnCond_Container = addContainer(DemGeneralSUB_CONTAINERS_el,'DemEnableConditionGroup_' + str(DemEnCondGroupKey),'ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemGeneral/DemEnableConditionGroup')
        
        DemEnCond_REFERENCE_VALUES = SubElement(DemEnCond_Container,'REFERENCE-VALUES')

        for DemEnCond in DemEnCondList:
            addReference(DemEnCond_REFERENCE_VALUES,'ECUC-REFERENCE-DEF',\
                            r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemGeneral/DemEnableConditionGroup/DemEnableConditionRef',\
                            r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemGeneral/DemEnableCondition_' + DemEnCond)

    def addDtcEnableCondition_cfg(self,DemEnCond):
        if self.DemContainers_el == 'no define':
            self.DemContainers_el = addModule(self.Project_el,'Dem',r'/AUTOSAR_Dem/EcucModuleDefs/Dem')
        if self.DemGeneralContainers_el == 'no define':
            self.DemGeneralContainers_el = addContainer(self.DemContainers_el,'DemGeneral','ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemGeneral')
            self.DemGeneralContainers_el = SubElement(self.DemGeneralContainers_el,'SUB-CONTAINERS')
            
        DemGeneralSUB_CONTAINERS_el = self.DemGeneralContainers_el

        DemEnCond_Container = addContainer(DemGeneralSUB_CONTAINERS_el,'DemEnableCondition_' + DemEnCond,'ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemGeneral/DemEnableCondition')
        
        DemEnCond_PARAMETER_VALUES = SubElement(DemEnCond_Container,'PARAMETER-VALUES')

        addParameter(DemEnCond_PARAMETER_VALUES,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-BOOLEAN-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemGeneral/DemEnableCondition/DemEnableConditionStatus',\
                        'false')
                    
    def addDtc_cfg(self,DemDtcCfg: DemDtcCfg):
        if self.DemContainers_el == 'no define':
            self.DemContainers_el = addModule(self.Project_el,'Dem',r'/AUTOSAR_Dem/EcucModuleDefs/Dem')

        if self.DemConfigSetContainers_el == 'no define':
            self.DemConfigSetContainers_el = addContainer(self.DemContainers_el,'DemConfigSet','ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet')
            self.DemConfigSetContainers_el = SubElement(self.DemConfigSetContainers_el,'SUB-CONTAINERS')

        DemConfigSetSUB_CONTAINERS_el = self.DemConfigSetContainers_el
        for event in DemDtcCfg.eventList:
            CONTAINER_DemEventParameter_el = addContainer(DemConfigSetSUB_CONTAINERS_el,event,'ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter')

            DemEvent_PARAMETER_VALUES = SubElement(CONTAINER_DemEventParameter_el,'PARAMETER-VALUES')
            addParameter(DemEvent_PARAMETER_VALUES,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemEventFailureCycleCounterThreshold',\
                            '1')
            addParameter(DemEvent_PARAMETER_VALUES,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-BOOLEAN-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemFFPrestorageSupported',\
                            '0')
            addParameter(DemEvent_PARAMETER_VALUES,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-BOOLEAN-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemEventAvailable',\
                            'true')
            addParameter(DemEvent_PARAMETER_VALUES,'ECUC-TEXTUAL-PARAM-VALUE','ECUC-ENUMERATION-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemEventKind',\
                            'DEM_EVENT_KIND_SWC')
            
            DemEvent_REFERENCE_VALUES = SubElement(CONTAINER_DemEventParameter_el,'REFERENCE-VALUES')
            addReference(DemEvent_REFERENCE_VALUES,'ECUC-REFERENCE-DEF',\
                         r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemOperationCycleRef',\
                         r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemGeneral/DemOperationCycle')
            addReference(DemEvent_REFERENCE_VALUES,'ECUC-REFERENCE-DEF',\
                         r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemComponentClassRef',\
                         r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemConfigSet/DemComponent_' + DemDtcCfg.dtcName)
            addReference(DemEvent_REFERENCE_VALUES,'ECUC-REFERENCE-DEF',\
                         r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemDTCRef',\
                         r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemConfigSet/DemDTC_' + DemDtcCfg.dtcName)
            addReference(DemEvent_REFERENCE_VALUES,'ECUC-REFERENCE-DEF',\
                         r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemEnableConditionGroupRef',\
                         r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemGeneral/DemEnableConditionGroup_' + str(DemDtcCfg.dtcEnCondGroupNum))

            DemEventParameterSUB_CONTAINERS_el = SubElement(CONTAINER_DemEventParameter_el,'SUB-CONTAINERS')

            CONTAINER_DemDebounceAlgorithmClass_el = addContainer(DemEventParameterSUB_CONTAINERS_el,'DemDebounceAlgorithmClass_0','ECUC-CHOICE-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemDebounceAlgorithmClass')
            DemDebounceAlgorithmClassSUB_CONTAINERS_el = SubElement(CONTAINER_DemDebounceAlgorithmClass_el,'SUB-CONTAINERS')

            debouce_List = DemDtcCfg.debounce.split('_')
            if debouce_List[0] == 'C':
                CONTAINER_DemDebounceCounterBased_el = addContainer(DemDebounceAlgorithmClassSUB_CONTAINERS_el,'DemDebounceCounterBased','ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemDebounceAlgorithmClass/DemDebounceCounterBased')
                DemDebounceCounterBased_REFERENCE_VALUES_el = SubElement(CONTAINER_DemDebounceCounterBased_el,'REFERENCE-VALUES')
                addReference(DemDebounceCounterBased_REFERENCE_VALUES_el,'ECUC-REFERENCE-DEF',\
                            r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemDebounceAlgorithmClass/DemDebounceCounterBased/DemDebounceCounterBasedClassRef',\
                            rf'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemConfigSet/{DemDtcCfg.debounce}')            
            if debouce_List[0] == 'T':
                CONTAINER_DemDebounceCounterBased_el = addContainer(DemDebounceAlgorithmClassSUB_CONTAINERS_el,'DemDebounceTimeBase','ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemDebounceAlgorithmClass/DemDebounceTimeBase')
                DemDebounceCounterBased_REFERENCE_VALUES_el = SubElement(CONTAINER_DemDebounceCounterBased_el,'REFERENCE-VALUES')
                addReference(DemDebounceCounterBased_REFERENCE_VALUES_el,'ECUC-REFERENCE-DEF',\
                            r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemDebounceAlgorithmClass/DemDebounceTimeBase/DemDebounceTimeBaseRef',\
                            rf'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemConfigSet/{DemDtcCfg.debounce}')                            
            
            CONTAINER_DemRbEventClass_el = addContainer(DemEventParameterSUB_CONTAINERS_el,'DemRbEventClass_0','ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemRbEventClass')
            DemRbEventClass_PARAMETER_VALUES = SubElement(CONTAINER_DemRbEventClass_el,'PARAMETER-VALUES')
            addParameter(DemRbEventClass_PARAMETER_VALUES,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemRbEventClass/DemRbEventBufferTime',\
                            '0')
            addParameter(DemRbEventClass_PARAMETER_VALUES,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-BOOLEAN-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemRbEventClass/DemRbEventRecoverableInSameOperationCycle',\
                            '1')
            addParameter(DemRbEventClass_PARAMETER_VALUES,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-BOOLEAN-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemEventParameter/DemRbEventClass/DemRbEventStatusBitStorageTestFailed',\
                            '0')
            
        CONTAINER_DemComponent_el = addContainer(DemConfigSetSUB_CONTAINERS_el,'DemComponent_' + DemDtcCfg.dtcName,'ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemComponent')
        DemComponent_PARAMETER_VALUES_el = SubElement(CONTAINER_DemComponent_el,'PARAMETER-VALUES')
        addParameter(DemComponent_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-BOOLEAN-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemComponent/DemComponentIgnoresPriority',\
                        'FALSE')
        addParameter(DemComponent_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-BOOLEAN-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemComponent/DemComponentFailedCallbackUsePort',\
                        'FALSE')
        
        DemComponent_REFERENCE_VALUES_el = SubElement(CONTAINER_DemComponent_el,'REFERENCE-VALUES')
        addReference(DemComponent_REFERENCE_VALUES_el,'ECUC-REFERENCE-DEF',\
                         r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemComponent/DemImmediateChildComponentRef',\
                         r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemConfigSet/DemComponent_' + DemDtcCfg.dtcName)
        
        CONTAINER_DemDTCAttributes_el = addContainer(DemConfigSetSUB_CONTAINERS_el,'DemDTCAttributes_' + DemDtcCfg.dtcName,'ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes')
        DemDTCAttributes_PARAMETER_VALUES_el = SubElement(CONTAINER_DemDTCAttributes_el,'PARAMETER-VALUES')
        addParameter(DemDTCAttributes_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-BOOLEAN-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes/DemAgingAllowed',\
                        'true')
        addParameter(DemDTCAttributes_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes/DemAgingCycleCounterThreshold',\
                        '40')
        addParameter(DemDTCAttributes_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes/DemDTCPriority',\
                        '1')
        addParameter(DemDTCAttributes_PARAMETER_VALUES_el,'ECUC-TEXTUAL-PARAM-VALUE','ECUC-ENUMERATION-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes/DemDTCSignificance',\
                        'DEM_EVENT_SIGNIFICANCE_FAULT')
        addParameter(DemDTCAttributes_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-BOOLEAN-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes/DemImmediateNvStorage',\
                        'FALSE')
        addParameter(DemDTCAttributes_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes/DemMaxNumberFreezeFrameRecords',\
                        '1')
        DemDTCAttributes_REFERENCE_VALUES_el = SubElement(CONTAINER_DemDTCAttributes_el,'REFERENCE-VALUES')
        addReference(DemDTCAttributes_REFERENCE_VALUES_el,'ECUC-REFERENCE-DEF',\
                         r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes/DemAgingCycleRef',\
                         r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemGeneral/DemOperationCycle')
        addReference(DemDTCAttributes_REFERENCE_VALUES_el,'ECUC-REFERENCE-DEF',\
                         r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes/DemExtendedDataClassRef',\
                         r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemGeneral/DemExtendedDataClass')
        addReference(DemDTCAttributes_REFERENCE_VALUES_el,'ECUC-REFERENCE-DEF',\
                         r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes/DemFreezeFrameClassRef',\
                         r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemGeneral/DemFreezeFrameClass_01')
        addReference(DemDTCAttributes_REFERENCE_VALUES_el,'ECUC-REFERENCE-DEF',\
                         r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes/DemFreezeFrameRecNumClassRef',\
                         r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemGeneral/DemFreezeFrameRecNumClass')
        addReference(DemDTCAttributes_REFERENCE_VALUES_el,'ECUC-CHOICE-REFERENCE-DEF',\
                         r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTCAttributes/DemMemoryDestinationRef',\
                         r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemGeneral/DemPrimaryMemory')
        
        CONTAINER_DemDTC_el = addContainer(DemConfigSetSUB_CONTAINERS_el,'DemDTC_' + DemDtcCfg.dtcName,'ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTC')
        DemDTC_PARAMETER_VALUES_el = SubElement(CONTAINER_DemDTC_el,'PARAMETER-VALUES')
        addParameter(DemDTC_PARAMETER_VALUES_el,'ECUC-TEXTUAL-PARAM-VALUE','ECUC-ENUMERATION-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTC/DemDTCSeverity',\
                        'DEM_SEVERITY_NO_SEVERITY')
        addParameter(DemDTC_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTC/DemDTCFunctionalUnit',\
                        '0')
        addParameter(DemDTC_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                    r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTC/DemDtcValue',\
                        str(int(DemDtcCfg.DtcNum,16)))
        DemDTC_REFERENCE_VALUES_el = SubElement(CONTAINER_DemDTC_el,'REFERENCE-VALUES')
        addReference(DemDTC_REFERENCE_VALUES_el,'ECUC-REFERENCE-DEF',\
                         r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDTC/DemDTCAttributesRef',\
                         r'/ETAS_Project/EcucModuleConfigurationValuess/Dem/DemConfigSet/DemDTCAttributes_' + DemDtcCfg.dtcName)

    def addDebounce_cfg(self,debounce:str):
        if self.DemContainers_el == 'no define':
            self.DemContainers_el = addModule(self.Project_el,'Dem',r'/AUTOSAR_Dem/EcucModuleDefs/Dem')

        if self.DemConfigSetContainers_el == 'no define':
            self.DemConfigSetContainers_el = addContainer(self.DemContainers_el,'DemConfigSet','ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet')
            self.DemConfigSetContainers_el = SubElement(self.DemConfigSetContainers_el,'SUB-CONTAINERS')

        DemConfigSetSUB_CONTAINERS_el = self.DemConfigSetContainers_el

        debouce_List = debounce.split('_')
        if debouce_List[0] == 'C':

            failedIncreaseCnt = debouce_List[1]
            passDecreaseCnt = debouce_List[2]
            failedMaxCnt = debouce_List[3]
            passMaxCnt = '-1'
            passJumpCnt = str(int(failedMaxCnt) - 1)
            CONTAINER_DemDebounceParameter_el = addContainer(DemConfigSetSUB_CONTAINERS_el,debounce,'ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceCounterBasedClass')
            DemDebouunce_PARAMETER_VALUES_el = SubElement(CONTAINER_DemDebounceParameter_el,'PARAMETER-VALUES')
            addParameter(DemDebouunce_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-BOOLEAN-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceCounterBasedClass/DemDebounceCounterJumpDown',\
                            "true")
            addParameter(DemDebouunce_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceCounterBasedClass/DemDebounceCounterJumpDownValue',\
                            passJumpCnt)
            addParameter(DemDebouunce_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-BOOLEAN-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceCounterBasedClass/DemDebounceCounterStorage',\
                            0)
            addParameter(DemDebouunce_PARAMETER_VALUES_el,'ECUC-TEXTUAL-PARAM-VALUE','ECUC-ENUMERATION-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceCounterBasedClass/DemDebounceBehavior',\
                            "DEM_DEBOUNCE_RESET")
            addParameter(DemDebouunce_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceCounterBasedClass/DemDebounceCounterFailedThreshold',\
                            failedMaxCnt)
            addParameter(DemDebouunce_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceCounterBasedClass/DemDebounceCounterPassedThreshold',\
                            passMaxCnt)
            addParameter(DemDebouunce_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceCounterBasedClass/DemDebounceCounterDecrementStepSize',\
                            passDecreaseCnt)
            addParameter(DemDebouunce_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-INTEGER-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceCounterBasedClass/DemDebounceCounterIncrementStepSize',\
                            failedIncreaseCnt)

        if debouce_List[0] == 'T':

            failedIncreaseTime = str(float(int(debouce_List[1])/1000))
            passDecreaseTime = str(float(int(debouce_List[2])/1000))
            CONTAINER_DemDebounceParameter_el = addContainer(DemConfigSetSUB_CONTAINERS_el,debounce,'ECUC-PARAM-CONF-CONTAINER-DEF',r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceTimeBaseClass')
            DemDebouunce_PARAMETER_VALUES_el = SubElement(CONTAINER_DemDebounceParameter_el,'PARAMETER-VALUES')
            addParameter(DemDebouunce_PARAMETER_VALUES_el,'ECUC-TEXTUAL-PARAM-VALUE','ECUC-ENUMERATION-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceTimeBaseClass/DemDebounceBehavior',\
                            "DEM_DEBOUNCE_RESET")
            addParameter(DemDebouunce_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-FLOAT-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceTimeBaseClass/DemDebounceTimeFailedThreshold',\
                            failedIncreaseTime)
            addParameter(DemDebouunce_PARAMETER_VALUES_el,'ECUC-NUMERICAL-PARAM-VALUE','ECUC-FLOAT-PARAM-DEF',\
                        r'/AUTOSAR_Dem/EcucModuleDefs/Dem/DemConfigSet/DemDebounceTimeBaseClass/DemDebounceTimePassedThreshold',\
                            passDecreaseTime)
                         